{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\u001b[1m(logscale) Histogram\t(entries=100000)\n",
      "4.89 ▉                   \n",
      "   | ▉                   \n",
      "   | ▉                   \n",
      "   | ▉▉                  \n",
      "   | ▉▉▉▉▉▉▉▉▉▉▉▉        \n",
      "   | ▉▉▉▉▉▉▉▉▉▉▉▉▉▉      \n",
      "   | ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉    \n",
      "   | ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉   \n",
      "   | ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ \n",
      "   | ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉\n",
      "0.00....................148.00\n",
      "\u001b[0m\n"
     ]
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "1c76ae9e646248eb885bc298c47f1e1a",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "Plot(antialias=3, axes=['x', 'y', 'z'], background_color=16777215, camera=[12473.41530203239, 12265.3379094542…"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "\"\"\"Represent a volume as lego blocks (voxels). Colors correspond to the volume's scalar.\"\"\"\n",
    "\n",
    "# https://matplotlib.org/users/colormaps.html\n",
    "from vtkplotter import *\n",
    "\n",
    "#embedWindow('itkwidgets')\n",
    "\n",
    "vol = load(datadir+'embryo.tif') # load Volume\n",
    "printHistogram(vol, logscale=True)\n",
    "\n",
    "vol.crop(back=0.5) # crop 50% from neg. y\n",
    "\n",
    "# show lego blocks whose value is between vmin and vmax\n",
    "lego = vol.legosurface(vmin=60, cmap='seismic')\n",
    "\n",
    "lego.addScalarBar(vmin=40, horizontal=1) # make colormap start at 40\n",
    "\n",
    "show(lego, viewup='z')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
